#include "calculator.h"
#include "ui_calculator.h"
Calculator::Calculator(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Calculator)
{
    ui->setupUi(this);
    on_tb_clear_clicked();
    m_model = 0;
}
Calculator::~Calculator()
{
    delete ui;
}
void Calculator::on_tb_num0_clicked()
{
    clickedNumber(ui->tb_num0->text());
}
void Calculator::on_tb_num1_clicked()
{
    clickedNumber(ui->tb_num1->text());
}
void Calculator::on_tb_num2_clicked()
{
    clickedNumber(ui->tb_num2->text());
}
void Calculator::on_tb_num3_clicked()
{
    clickedNumber(ui->tb_num3->text());
}
void Calculator::on_tb_num4_clicked()
{
    clickedNumber(ui->tb_num4->text());
}
void Calculator::on_tb_num5_clicked()
{
    clickedNumber(ui->tb_num5->text());
}
void Calculator::on_tb_num6_clicked()
{
    clickedNumber(ui->tb_num6->text());
}
void Calculator::on_tb_num7_clicked()
{
    clickedNumber(ui->tb_num7->text());
}
void Calculator::on_tb_num8_clicked()
{
    clickedNumber(ui->tb_num8->text());
}
void Calculator::on_tb_num9_clicked()
{
    clickedNumber(ui->tb_num9->text());
}
void Calculator::clickedNumber(const QString &t)
{
    m_value += t;
    m_expretion += t;
    ui->lb_expretion->setText(m_expretion);
}
void Calculator::on_tb_add_clicked()
{
    middleResult();
    m_operator = FLAG_OPERATOR_ADD;
    m_expretion += ui->tb_add->text();
    ui->lb_expretion->setText(m_expretion);
}
void Calculator::on_tb_mul_clicked()
{
    middleResult();
    m_operator = FLAG_OPERATOR_MUL;
    m_expretion += ui->tb_mul->text();
    ui->lb_expretion->setText(m_expretion);
}
void Calculator::on_tb_div_clicked()
{
    middleResult();
    m_operator = FLAG_OPERATOR_DIV;
    m_expretion += ui->tb_div->text();
    ui->lb_expretion->setText(m_expretion);
}
